<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <!--引入分页-->
    <link rel="stylesheet" href="../../../lib/pagination/pagination.css">
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="../../../lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/style.css"/>
    <!--表单验证-->
    <link rel="stylesheet" type="text/css" href="../../../lib/Validform/5.3.2/style.css" />
    <link rel="stylesheet" type="text/css" href="../../../ht-css/Project.css"/>
    <link rel="stylesheet" href="../../../ht-css/combo.select.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../../ht-css/style-q.css"/>
    <title>SPU详情</title>
    <style>
        html {
            zoom: .80
        }
    </style>
</head>
<body data-id="607">
<nav class="breadcrumb">对接平台管理 <span class="c-gray en">&gt;</span> 渠道商品管理 <span class="c-gray en">&gt;</span> spu展示 <span
        class="c-gray en">&gt;</span> SPU<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <div class="ml-20 mr-20" id="spuInfo" method="post">
        <div id="tab_topnav" class="HuiTab">
            <div class="tabBar clearfix"><span>spu展示</span><!--<span>商品图片管理</span>--></div>
            <!--SPU详情-->
            <div class="tabCon bg-1 bk-gray pd-20 mb-20">
                <div class="va-m lh-20 f-16 pb-15">
                    <strong>基本信息</strong>
                </div>
                <div class="line"></div>
                <div class="pd-20">
                    <div class="mb-15"> SPU：<span id="spu_code"></span></div>
                    <div class="clearfix mb-15"><span class="c-red pr-5 f-l">*</span><label class="f-l">商品名称：</label>
                        <div class="formControls col-sm-5">
                            <textarea onblur="isNull()" class="textarea" id="goodsName" name="goodsName"></textarea>
                            <span class="errorMsg hide" style="color: red;">名称不能为空</span>
                        </div>
                    </div>
                    <div class="clearfix mb-15">
                        <span class="c-red pr-5 f-l">&nbsp;</span><label class="f-l">商品别名：</label>
                        <div class="f-l col-2-1">
                            <div class="clearfix mb-5" id="anotherNameBox">
                                <div id="inpBox">

                                </div>
                                <a href="##" onclick="nameAdd()">添加</a>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix mb-15">
                        <span class="c-red pr-5 f-l">*</span>
                        <label class="f-l">所属品牌：</label>
                        <span class="f-l">
                            <span class="pd-15" id="brandName" name=""></span>
                            <span class="brandErrorMsg hide" style="color: red;">名称不能为空</span>
                            <span id="brandId" style="display:none;"></span>
                            <a onclick="selectBrand()" class="btn btn-secondary radius size-S botter">选择</a>
                        </span>
                        <div id="selectInp" class="ml-15 f-l" style="display:none;">
                            <div style="position: relative" class="f-l">
                                <input type="text" class="input-text radius"  name="moli" onfocus="myFunction()"  placeholder="" oninput="myFunction()" id="username">
                                <ul class="relation radius guanlian" id="tuan">
                                    <li>无数据</li>
                                </ul>
                            </div>
                            <a class="pd-5 f-l ml-10" onclick="brand_sure()">确定</a>
                            <a class="pd-5 f-l" onclick="brand_cancel()">取消</a>
                        </div>
                    </div>
                    <div class="clearfix mb-15">
                        <label class="f-l">商品副标题：</label>
                        <div class="formControls col-sm-5"><textarea name="" class="textarea" id="subtitile"></textarea></div>
                        <span class="subtitileErrorMsg hide" style="color: red;">超出字符限制</span>
                    </div>
                    <div class="clearfix mb-15"><span class="c-red pr-5 f-l">*</span><label class="f-l">所属分类：</label><span id="categoryName"></span>
                    </div>
                    <div class="clearfix mb-15"><label class="f-l">是否限制类：</label>
                        <span id="categoryName2" class="select-box size-M radius col-xs-8 ml-10" style="width: 30%">
                            <select class="select" id="isLimitCategory" name="isLimitCategory" size="1">
                                <option value="-1" selected>---请选择限制内容---</option>
                                <option value="0">非限制类</option>
                                 <option value="1">危化品</option>
                                 <option value="2">管制刀具</option>
                            </select>
                        </span>
                    </div>
                   <!-- <div class="clearfix mb-15"><span class="pr-5 f-l">&nbsp;&nbsp;</span><label class="f-l">商品标准：</label>
                        <span id="categoryName3" class="select-box size-M radius col-xs-8 ml-10" style="width: 30%">
                            <select class="select" id="spuStandards" name="spuStandards" size="1">
                                 <option value="0" selected>请选择标准</option>
                                 <option value="1">国标</option>
                                 <option value="2">无标准无下差</option>
                                 <option value="3">无标准有下差</option>
                                 <option value="4">其他</option>
                            </select>
                        </span>
                        <label class="f-l gbnumber" style="display:none" >&nbsp;&nbsp;标准号：</label>
                        <div class="formControls col-sm-5"><input class="input-text radius gbnumber"  id="GBNumber" style="width:250px;display:none"></input></div>
                    </div>-->
                    <div class="clearfix mb-15"><span class="pr-5 f-l">&nbsp;&nbsp;</span><label class="f-l">客户类型：</label>
                        <div class="formControls col-sm-5  ml-8">
                            <input type="checkbox" value="2" name = "customerType">普通客户&nbsp;
                            <input type="checkbox" value="1" name = "customerType">签约客户
                        </div>
                    </div>
                    <div class="clearfix mb-15"><span class="c-red pr-5 f-l">*</span><label class="f-l">售卖信息：</label>
                        <div class="formControls col-sm-5  ml-8">
                            <span id="spuinfos"></span>
                        </div>
                    </div>
                </div>

                <div class="va-m lh-20 f-16 pb-15">
                    <strong>商品描述信息字段</strong>
                </div>
                <div class="line"></div>
                <table id="attrTable" class="table table-border table-bordered table-bg mt-15 mb-30">
                    <thead>
                    <tr>
                        <th class="col-6-1 text-c">品牌</th>
                        <td><span id="brand"></span></td>
                    </tr>
                    <tr>
                        <th class="col-6-1 text-c">包装清单</th>
                        <td><span id="pack_list"></span></td>
                    </tr>
                    <!--<tr>
                        <th class="col-6-1 text-c">生产标准</th>
                        <td id="productionStandard"></td>
                    </tr>-->
                    </thead>
                </table>

                <div class="va-m lh-20 f-16 pb-15">
                    <strong>图片信息</strong>
                </div>
                <div class="line"></div>
                <div class="mt-15 mb-30 imgTable clearfix">
                    <ul class="imgboxUl f-l">

                    </ul>
                    <ul class="f-l ml-5 addSpuImgbox">
                        <li class="col-5-1 text-c va-t">
                            <span id="addSpuImg" class="spu_add_img">

                            </span>
                        </li>
                    </ul>
                </div>

                <div class="va-m lh-20 f-16 pb-15">
                    <strong>详情信息</strong>
                </div>
                <div class="line"></div>
                <div class="pd-20">
                    <script id="editor" type="text/plain" style="width: 100%; height: 500px"></script></div>
                <div class="text-c mb-10">
                    <input id="sureBtn" type="button" onclick="makeSure()" class="btn btn-secondary radius size-S botter" value="&nbsp;确&nbsp;&nbsp;认&nbsp;">
                    <input type="button" class="btn radius size-S botter ml-10" onclick="cancleSpu()" value="&nbsp;取&nbsp;&nbsp;消&nbsp;">
                </div>
            </div>

            <!--商品图片管理-->
            <div class="tabCon pd-5 bg-1 bk-gray pb-10">
                <div class="lh-30 pd-10">
                    <form name="name2" id="spuPicForm">
                        <table class="table-hover table_li ml-10 mb-10 table">
                            <thead class="text-l">
                            <tr>
                                <td colspan="3" class="col-1-1">
                                    <div class="row ml-10" >
                                        <label class="form-label f-l pt-5">商品分类：</label>
                                        <span class="size-M radius col-xs-8 f-l" style="width:15%">
                                     <div style="position: relative;z-index: 900;">
                                          <input type="text" autocomplete="off" class="input-text radius" name="imgClass1" placeholder="请选择一级分类" oninput="imgGoods_listCategory(1)" id="imgClass1" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5、]{0,20}$/" errormsg="格式错误，请重新输入" ignore="ignore">
                                          <ul class="relation radius guanlian" id="img-classUl1">

                                          </ul>
                                      </div>
                                      <span class="Validform_checktip"></span>
                                  </span>
                                        <span class="f-l pl-10 pr-10 pt-5">~</span>
                                        <span class="size-M radius col-xs-8 f-l" style="width:15%">
                                      <div style="position: relative;z-index: 900;">
                                          <input type="text" autocomplete="off" class="input-text radius"  name="imgClass2"  placeholder="请选择二级分类" id="imgClass2" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5]{0,20}$/" errormsg="格式错误，请重新输入" ignore="ignore">
                                          <ul class="relation radius guanlian" id="img-classUl2">
                                          </ul>
                                      </div>
                                      <span class="Validform_checktip"></span>
                                  </span>
                                        <span class="f-l pl-10 pr-10 pt-5">~</span>
                                        <span class="size-M radius col-xs-8" style="width:15%">
                                      <div style="position: relative;z-index: 900;">
                                          <input type="text" autocomplete="off" class="input-text radius"  name="imgClass3" placeholder="请选择三级分类" id="imgClass3" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5]{0,20}$/" errormsg="格式错误，请重新输入" ignore="ignore">
                                          <ul class="relation radius guanlian" id="img-classUl3">
                                          </ul>
                                      </div>
                                      <span class="Validform_checktip"></span>
                                  </span>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="col-3-1">
                                    <div class="row ml-10">
                                        <label class="form-label f-l pt-5">图片名称：</label>
                                        <div class="formControls col-xs-8 col-sm-9">
                                            <input type="text" class="input-text radius"  name="imgname" id="imgName"  placeholder="输入图片名称关键字" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5]{0,50}$/" errormsg="格式错误，请重新输入" ignore="ignore">
                                        </div>
                                        <span class="Validform_checktip"></span>
                                    </div>
                                </td>
                                <td class="col-3-1">
                                    <div class="row ml-10">
                                        <label class="form-label f-l pt-5">SPU码：</label>
                                        <div class="formControls col-xs-8 col-sm-9">
                                            <input type="text" class="input-text radius" name="spuCode" id= "spuCode"
                                                   placeholder="输入SPU码" datatype="n0-11" errormsg="格式错误，请重新输入" ignore="ignore">
                                        </div>
                                        <span class="Validform_checktip"></span>
                                    </div>
                                </td>
                                <td class="col-3-1">
                                    <div class="row ml-10">
                                        <label class="form-label f-l pt-5">SKU码：</label>
                                        <div class="formControls col-xs-8 col-sm-9">
                                            <input type="text" class="input-text radius" name="skuCode" id= "skuCode"
                                                   placeholder="输入SKU码" datatype="n0-11" errormsg="格式错误，请重新输入" ignore="ignore">
                                        </div>
                                        <span class="Validform_checktip"></span>
                                    </div>
                                </td>
                            </tr>
                            </thead>
                        </table>
                        <div class="text-c mb-10">
                            <input id="btn" type="submit" class="btn btn-secondary radius size-S botter" value="&nbsp;查&nbsp;&nbsp;询&nbsp;">
                            <input name="" type="reset" onclick="resetDiv()" class="btn radius size-S botter ml-10" value="&nbsp;重&nbsp;&nbsp;置&nbsp;">
                        </div>
                    </form>
                    <div class="text-l pl-20 pb-10 clearfix"><input class="btn radius btn-secondary-outline radius f-l" onclick="addImg()" type="button" value="新增"></div>
                    <div class="line"></div>
                    <ul id="imgListBox" class="sale_pic clearfix">

                    </ul>
                    <div class="dataTables_wrapper goods_fanye clearfix">
                        <div class="f-r pageturning M-box3"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--表单验证-->
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
<script src="../../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script src="../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script src="../../../ht-js/coupon/coupon-topic.js?rev=@@hash"></script>
<script src="../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../ht-js/dockingplatform/goods/spu-info.js?rev=@@hash"></script>
<script src="../../../ht-js/dockingplatform/goods/pictures.js?rev=@@hash"></script>
<!--富文本编辑器-->
<script type="text/javascript" charset="utf-8" src="../../../lib/ueditor/1.4.3/ueditor.config.js?rev=@@hash"></script>
<script type="text/javascript" charset="utf-8" src="../../../lib/ueditor/1.4.3/ueditor.all.min.js?rev=@@hash"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../../../lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js?rev=@@hash"></script>
<script src="../../../ht-js/dynamicWarehouse.js?rev=@@hash"></script>

<script>

    $("#addSpuImg").click(function () {
        var imgLength= document.getElementsByClassName("imgboxUl")[0].children.length;
        sessionStorage.setItem("imgLength", JSON.stringify(imgLength));
        if(sessionStorage.getItem("spuImgCache")){
            var getSpuImgCache = sessionStorage.getItem("spuImgCache");
            var spuInfoImg = JSON.parse(getSpuImgCache);
            var spuInfoImgArr = Object.keys(spuInfoImg);
            addPic((spuInfoImgArr.length+1), true);
        }
    });

    var skuFormData = new FormData();
    var spuId = sessionStorage.getItem("spu_id");
    var spuImgCount = 0;
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor',{
        toolbars: [
            [
                'source', //源代码
                'anchor', //锚点
                'undo', //撤销
                'redo', //重做
                'bold', //加粗
                'indent', //首行缩进
                // 'snapscreen', //截图
                'italic', //斜体
                'underline', //下划线
                'strikethrough', //删除线
                'subscript', //下标
                'fontborder', //字符边框
                'superscript', //上标
                'formatmatch', //格式刷

                'blockquote', //引用
                'pasteplain', //纯文本粘贴模式
                'selectall', //全选
                'print', //打印
                'preview', //预览
                'horizontal', //分隔线
                'removeformat', //清除格式
                'time', //时间
                'date', //日期
                'unlink', //取消链接
                'insertrow', //前插入行
                'insertcol', //前插入列
                'mergeright', //右合并单元格
                'mergedown', //下合并单元格
                'deleterow', //删除行
                'deletecol', //删除列
                'splittorows', //拆分成行
                'splittocols', //拆分成列
                'splittocells', //完全拆分单元格
                'deletecaption', //删除表格标题
                'inserttitle', //插入标题
                'mergecells', //合并多个单元格
                'deletetable', //删除表格
                'cleardoc', //清空文档
                'insertparagraphbeforetable', //”表格前插入行”
                'insertcode', //代码语言
                'fontfamily', //字体
                'fontsize', //字号
                'paragraph', //段落格式
                /*'simpleupload', //单图上传
                'insertimage', //多图上传*/
                'edittable', //表格属性
                'edittd', //单元格属性
                'link', //超链接
                'emotion', //表情
                'spechars', //特殊字符
                'searchreplace', //查询替换
                'map', //Baidu地图
                'gmap', //Google地图
                'insertvideo', //视频
                'help', //帮助
                'justifyleft', //居左对齐
                'justifyright', //居右对齐
                'justifycenter', //居中对齐
                'justifyjustify', //两端对齐
                'forecolor', //字体颜色
                'backcolor', //背景色
                'insertorderedlist', //有序列表
                'insertunorderedlist', //无序列表
                'fullscreen', //全屏
                'directionalityltr', //从左向右输入
                'directionalityrtl', //从右向左输入
                'rowspacingtop', //段前距
                'rowspacingbottom', //段后距
                'pagebreak', //分页
                'insertframe', //插入Iframe
                'imagenone', //默认
                'imageleft', //左浮动
                'imageright', //右浮动
                // 'attachment', //附件
                'imagecenter', //居中
                'wordimage', //图片转存
                'lineheight', //行间距
                'edittip ', //编辑提示
                'customstyle', //自定义标题
                'autotypeset', //自动排版
                'webapp', //百度应用
                'touppercase', //字母大写
                'tolowercase', //字母小写
                'background', //背景
                'template', //模板
                'scrawl', //涂鸦
                'music', //音乐
                'inserttable', //插入表格
                'drafts', // 从草稿箱加载
                // 'charts', // 图表
            ]
        ]
    });
    UE.registerUI('dialog',function(editor,uiName){
            sessionStorage.setItem("skuOrSpu", "spu");
            //创建dialog
            var dialog = new UE.ui.Dialog({
                //指定弹出层中页面的路径，这里只能支持页面,因为跟addCustomizeDialog.js相同目录，所以无需加路径
                iframeUrl:'spuPictures.html',
                //需要指定当前的编辑器实例
                editor:editor,
                //指定dialog的名字
                name:uiName,
                //dialog的标题
                title:"请选择图片",
                //指定dialog的外围样式
                cssRules:"width:1366px;height:500px;",
                //如果给出了buttons就代表dialog有确定和取消
                buttons:[
                    {
                        className:'edui-okbutton',
                        label:'确定',
                        onclick:function () {
                            var selectNum = sessionStorage.getItem("selectNum");
                            if (selectNum != null) {
                                var selectPic = JSON.parse(sessionStorage.getItem("selectPic"));
                                var value = "";
                                for (var i = 0; i < selectPic.length; i++) {
                                    value += "<img src='" + selectPic[i] + "'>"
                                }
                                UE.getEditor('editor').execCommand('insertHtml', value)
                                sessionStorage.removeItem("selectNum");
                                sessionStorage.removeItem("selectPic");
                                dialog.close(true);
                            } else {
                                img.show();
                                if(skuFormData != null){
                                    if (sessionStorage.getItem("imgFileList") == 0) {
                                        layer.msg("请选择图片！", {icon: 5,time: 2000});
                                        return false;
                                    }
                                    $.ajax({
                                        url: root.goodsInter.goods_saveDetailImages,
                                        cache: false,  //禁用缓存
                                        type: "POST",
                                        // 告诉jQuery不要去处理发送的数据
                                        processData: false,
                                        // 告诉jQuery不要去设置Content-Type请求头
                                        contentType: false,
                                        data: skuFormData,
                                        success: function (data) {
                                            if (data.errorCode == 0) {
                                                img.hide();
                                                for(var i = 0; i < data.imgList.length; i++){
                                                    var value = "<img src='" + data.imgList[i] + "'>";
                                                    UE.getEditor('editor').execCommand('insertHtml', value)
                                                }
                                                dialog.close(true);
                                            }
                                        }
                                    });
                                }
                            }

                        }
                    },
                    {
                        className:'edui-cancelbutton',
                        label:'取消',
                        onclick:function () {
                            sessionStorage.removeItem("selectNum");
                            sessionStorage.removeItem("selectPic");
                            dialog.close(false);
                        }
                    }
                ]});

            //参考addCustomizeButton.js
            var btn = new UE.ui.Button({
                name:'上传图片',
                title:'上传图片',
                //需要添加的额外样式，指定icon图标，这里默认使用一个重复的icon
                cssRules :'background-position: -726px -77px;',
                onclick:function () {
                    //渲染dialog
                    dialog.render();
                    dialog.open();
                }
            });

            return btn;
        }
        /*index 指定添加到工具栏上的那个位置，默认时追加到最后,editorId 指定这个UI是那个编辑器实例上的，默认是页面上所有的编辑器都会添加这个按钮*/);
    $.ajax({
        type: "POST",
        url: root.goodsInter.goods_getSpuDetail,
        cache: false,  //禁用缓存
        dataType: "json",
        data: {
            spuId : spuId
        },
        success: function (result) {
            console.log(result)
            if (result.errorCode == 0) {
                sessionStorage.setItem("spuInfo",JSON.stringify(result));
                sessionStorage.setItem("isSave", 1);// 修改是1 添加是0
                var spuResult = JSON.parse(sessionStorage.getItem("spuInfo"));
                $("#spu_code").html(spuResult.spu.spu_code);
                $("#goodsName").html(spuResult.spu.name);
                if(sessionStorage.getItem("alias_value")){
                    $("#another_name").html(spuResult.alias.alias_value);
                }else {
                    for(var i=0;i<spuResult.alias.length;i++){
                        $("#inpBox").append('<div class="formControls col-sm-9 f-l aliasInp"><input type="text" class="input-text radius f-l another_name" value="'+spuResult.alias[i].alias_value+'" name="another_name" style="width: 85%"><a onclick="nameDelete(this)" class="ml-20 f-l">删除</a></div>');
                    }
                }
                if(sessionStorage.getItem("brand_name")){
                    $("#brandName").html(sessionStorage.getItem("brand_name"));
                    $("#brandId").html(sessionStorage.getItem("brand_id"));
                }else {
                    $("#brandId").html(spuResult.spu.brand_id);
                    $("#brandName").html(spuResult.spu.brand_name);
                }
                $("#subtitile").val(spuResult.spu.subtitile);
                $("#categoryName").html(spuResult.spu.category_name);
                $("#brand").html(spuResult.spu.brand_name);
                $("#pack_list").html(spuResult.spu.pack_list);

               /* if(spuResult.spu.standards == 1){
                    $("#productionStandard").html("国标");
                }
                if(spuResult.spu.standards == 2){
                    $("#productionStandard").html("无标准无下差");
                }
                if(spuResult.spu.standards == 3){
                    $("#productionStandard").html("无标准有下差");
                }
                if(spuResult.spu.standards == 4){
                    $("#productionStandard").html("其他");
                }
                if(spuResult.spu.standards == 0){
                    $("#productionStandard").html("请选择标准内容");
                }*/

                //为新加的列设置值
                // 客户类型
                var checkboxval = spuResult.spu.customer_type;
                if(checkboxval == '3'){
                    $("input:checkbox[name = 'customerType' ][value='1']").attr('checked','true');
                    $("input:checkbox[name = 'customerType' ][value='2']").attr('checked','true');
                }else{
                    $("input:checkbox[name = 'customerType' ][value='" + checkboxval + "']").attr('checked','true');
                }

                // 是否限制类
                var isLimitCategoryval = spuResult.spu.restricted;
                $("#isLimitCategory option[value='" +isLimitCategoryval+ "']").attr("selected","selected");

                /*// 商品标准
                var spuStandardsval = spuResult.spu.standards;
                $("#spuStandards option[value='" +spuStandardsval+ "']").attr("selected","selected");
                if(spuStandardsval ==1){
                    $(".gbnumber").show();
                    $("#GBNumber").attr("value",spuResult.spu.standards_number);
                }
                */
                //售卖信息
                var saleMSgVal = spuResult.spu.sale_area;
                $(":radio[name='saleArea'][value='" +saleMSgVal+ "']").attr("checked", "checked");

                setTimeout(function(){
                    UE.getEditor('editor').setContent(spuResult.spu.detail,true);
                },200);

                if(sessionStorage.getItem("attrObjCanch")){
                    var attrObjCanch = JSON.parse(sessionStorage.getItem("attrObjCanch"));
                    for(var i = 0; i < attrObjCanch.length; i++){
                        var attrValStr="";
                        var attrIdsStr="";
                        if(attrObjCanch[i].value.length != 0){
                            for(var j = 0; j< attrObjCanch[i].value.length; j++){
                                attrValStr += attrObjCanch[i].value[j].attri_value + ";";
                                attrIdsStr += attrObjCanch[i].value[j].attri_value_id + ";";
                            }
                        }
                        $("#attrTable").append('<tr id = "appendAttr"><th class="col-6-1 text-c">'+attrObjCanch[i].attribute_name+'</th><td><span>'+attrValStr+'</span><a onclick="addAttr('+attrObjCanch[i].attribute_id+",'"+attrIdsStr+"'"+')">添加</a></td></tr>')
                    }
                }else {
                    for(var i=0;i<spuResult.attribute.length;i++){
                        var attrValStr="";
                        var attrIdsStr="";
                        if(spuResult.attribute[i].value.length != 0){
                            for(var j=0;j<spuResult.attribute[i].value.length;j++){
                                attrValStr += spuResult.attribute[i].value[j].attri_value+";";
                                attrIdsStr += spuResult.attribute[i].value[j].attri_value_id+";";
                            }
                        }
                        $("#attrTable").append('<tr id = "appendAttr"><th class="col-6-1 text-c">'+spuResult.attribute[i].attribute_name+'</th><td><span>'+attrValStr+'</span><a onclick="addAttr('+spuResult.attribute[i].attribute_id+",'"+attrIdsStr+"'"+')">添加</a></td></tr>')
                    }
                }
                /*-----------------------------------图片处理开始----------------------------------------*/
                if(sessionStorage.getItem("spuImgCache")){
                    var spuInfoImg = JSON.parse(sessionStorage.getItem("spuImgCache"));
                    var spuInfoImgArr = Object.keys(spuInfoImg);
                    for (var i = 0; i < spuInfoImgArr.length; i++) {
                        var img = "img" + (i + 1);
                        $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg' + (i + 1) + '" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\'' + spuInfoImg[img].imgUrl + '\')" src="' + spuInfoImg[img].imgUrl + '" width="150" height="150"></span><span id="spuImgId' + (i + 1) + '" style="display: none">' + spuInfoImg[img].imgId + '</span><span id="spuImgUrl' + (i + 1) + '" style="display: none">' + spuInfoImg[img].imgUrl + '</span><div id="btnBox' + (i + 1) + '" class="pt-10 updataBtn"><a onclick="editPic(' + (i + 1) + ', false)" class="pd-20">修改</a><a onclick="deletePic(' + (i + 1) + ')" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, ' + (i + 1) + ')" value="' + spuInfoImg[img].imgSort + '" id="spuImgSort' + (i + 1) + '" name="imgSort" style="width:40px"></div></div>');
                    }
                    /*for(item in spuInfoImg) {
                        if(item.endWith("1")){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg1" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId1" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl1" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox1" class="pt-10 updataBtn"><a onclick="editPic(1, false)" class="pd-20">修改</a><a onclick="deletePic(1)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 1)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort1" name="imgSort" style="width:40px"></div></div>')
                        }if(item.endWith("2")){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg2" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId2" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl2" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox2" class="pt-10 updataBtn"><a onclick="editPic(2, false)" class="pd-20">修改</a><a onclick="deletePic(2)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 2)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort2" name="imgSort" style="width:40px"></div></div>')
                        }if(item.endWith("3")){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg3" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId3" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl3" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox3" class="pt-10 updataBtn"><a onclick="editPic(3, false)" class="pd-20">修改</a><a onclick="deletePic(3)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 3)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort3" name="imgSort" style="width:40px"></div></div>')
                        }if(item.endWith("4")){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg4" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId4" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl4" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox4" class="pt-10 updataBtn"><a onclick="editPic(4, false)" class="pd-20">修改</a><a onclick="deletePic(4)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 4)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort4" name="imgSort" style="width:40px"></div></div>')
                        }if(item.endWith("5")){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg5" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId5" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl5" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox5" class="pt-10 updataBtn"><a onclick="editPic(5, false)" class="pd-20">修改</a><a onclick="deletePic(5)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 5)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort5" name="imgSort" style="width:40px"></div></div>');
                            /!*$(".addSpuImgbox").css({
                                display:"none"
                            })*!/
                        }
                    }*/
                }else {
                    var spuImgCache = {};
                    var spuInfoImg = spuResult.spu_img;
                    spuImgCount = spuInfoImg.length;
                    for(var i = 0; i < spuInfoImg.length; i++){
                        $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg' + (i + 1) + '" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\'' + spuInfoImg[i].img_url + '\')" src="' + spuInfoImg[i].img_url + '" width="150" height="150"></span><span id="spuImgId' + (i + 1) + '" style="display: none">' + spuInfoImg[i].img_id + '</span><span id="spuImgUrl' + (i + 1) + '" style="display: none">' + spuInfoImg[i].img_url + '</span><div id="btnBox' + (i + 1) + '" class="pt-10 updataBtn"><a onclick="editPic(' + (i + 1) + ', false)" class="pd-20">修改</a><a onclick="deletePic(' + (i + 1) + ')" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, ' + (i + 1) + ')" value="' + spuInfoImg[i].img_sort + '" id="spuImgSort' + (i + 1) + '" name="imgSort" style="width:40px"></div></div>');
                        spuImgCache["img" + (i + 1)] = {
                            imgId: spuInfoImg[i].img_id,
                            imgUrl: spuInfoImg[i].img_url,
                            imgSort: spuInfoImg[i].img_sort
                        };
                        /*if((i + 1) == 1){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg'+(i+1)+'" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId1" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl1" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox1" class="pt-10 updataBtn"><a onclick="editPic(1, false)" class="pd-20">修改</a><a onclick="deletePic(1)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 1)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort1" name="imgSort" style="width:40px"></div></div>')
                            spuImgCache["img"+(i+1)] = {
                                imgId: spuInfoImg[i].img_id,
                                imgUrl: spuInfoImg[i].img_url,
                                imgSort: spuInfoImg[i].img_sort
                            }
                        } else if((i + 1) == 2){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg2" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId2" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl2" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox2" class="pt-10 updataBtn"><a onclick="editPic(2, false)" class="pd-20">修改</a><a onclick="deletePic(2)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 2)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort2" name="imgSort" style="width:40px"></div></div>')
                            spuImgCache["img2"] = {
                                imgId: spuInfoImg[i].img_id,
                                imgUrl: spuInfoImg[i].img_url,
                                imgSort: spuInfoImg[i].img_sort
                            }
                        } else if((i + 1) == 3){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg3" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId3" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl3" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox3" class="pt-10 updataBtn"><a onclick="editPic(3, false)" class="pd-20">修改</a><a onclick="deletePic(3)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 3)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort3" name="imgSort" style="width:40px"></div></div>')
                            spuImgCache["img3"] = {
                                imgId: spuInfoImg[i].img_id,
                                imgUrl: spuInfoImg[i].img_url,
                                imgSort: spuInfoImg[i].img_sort
                            }
                        } else if((i + 1) == 4){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg4" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId4" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl4" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox4" class="pt-10 updataBtn"><a onclick="editPic(4, false)" class="pd-20">修改</a><a onclick="deletePic(4)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 4)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort4" name="imgSort" style="width:40px"></div></div>')
                            spuImgCache["img4"] = {
                                imgId: spuInfoImg[i].img_id,
                                imgUrl: spuInfoImg[i].img_url,
                                imgSort: spuInfoImg[i].img_sort
                            }
                        }else if((i + 1) == 5){
                            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg5" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId5" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl5" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox5" class="pt-10 updataBtn"><a onclick="editPic(5, false)" class="pd-20">修改</a><a onclick="deletePic(5)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 5)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort5" name="imgSort" style="width:40px"></div></div>')
                            spuImgCache["img5"] = {
                                imgId: spuInfoImg[i].img_id,
                                imgUrl: spuInfoImg[i].img_url,
                                imgSort: spuInfoImg[i].img_sort
                            }
                            /!*$(".addSpuImgbox").css({
                                display:"none"
                            })*!/
                        }*/
                    }
                    sessionStorage.setItem("spuImgCache", JSON.stringify(spuImgCache));
                    sessionStorage.setItem("imgLength", JSON.stringify(spuInfoImg.length));
                }
                /*-----------------------------------图片处理结束----------------------------------------*/
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });



    /*tab切换*/
    jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
        var $tab_menu = $(tabBar);
        // 初始化操作
        $tab_menu.removeClass(class_name);
        $(tabBar).eq(i).addClass(class_name);
        $(tabCon).hide();
        $(tabCon).eq(i).show();

        $tab_menu.bind(tabEvent, function () {
            $tab_menu.removeClass(class_name);
            $(this).addClass(class_name);
            var index = $tab_menu.index(this);
            $(tabCon).hide();
            $(tabCon).eq(index).show()
        })
    };
    $(function () {
        $.Huitab("#tab_topnav .tabBar span", "#tab_topnav .tabCon", "current", "click", "0")
    });
    // #tab_demo 父级id
    // #tab_demo .tabBar span 控制条
    // #tab_demo .tabCon 内容区
    // click 事件 点击切换，可以换成mousemove 移动鼠标切换
    // 1	默认第2个tab为当前状态（从0开始）
    function cancleSpu() {
        var ind = parent.layer.getFrameIndex(window.name);
        layer.confirm('确认要取消吗？',function(index){
            parent.layer.close(ind);
            layer.msg('已取消', {icon: 6,time:1000});
        });
    }
    $(function(){
        $("#spuPicForm").Validform({
            tiptype:2,
            callback:function(form){
                img_list();
                return false;
            }
        });
    });
</script>
</body>
</html>